package mia.entity;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="ADVERTISEMENTS")
public class AdvertisementEntity {

	@Id
	@GeneratedValue
	@Column(name="ADVER_ID")
	private int advertisement_id;
	
	@ManyToOne
	@JoinColumn(name="ADVER_USER_ID")
	private UserEntity user;
	
	@ManyToOne
	@JoinColumn(name="ADVER_CATEGORY_ID")
	private CategoryEntity category;
	
	@Column(name="ADVER_TITLE")
	private String title;
	
	@Column(name="ADVER_CONTENT")
	private String content;
	
	@ManyToOne
	@JoinColumn(name="ADVER_TYPE_ID")
	private AdvertisementTypeEntity type;
	
	@Column(name="ADVER_START_DATE")
	private Date startDate;
	
	@Column(name="ADVER_EXPIRE_DATE")
	private Date expireDate;
	
	@OneToMany(mappedBy="advertisement", cascade=CascadeType.ALL)
	
	private Collection<AttachmentEntity> attachments = new ArrayList<AttachmentEntity>();
	
	// GETTERS AND SETTERS

	public int getAdvertisement_id() {
		return advertisement_id;
	}
	public void setAdvertisement_id(int advertisement_id) {
		this.advertisement_id = advertisement_id;
	}
	public UserEntity getUser() {
		return user;
	}
	public void setUser(UserEntity user) {
		this.user = user;
	}
	public CategoryEntity getCategory() {
		return category;
	}
	public void setCategory(CategoryEntity category) {
		this.category = category;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public AdvertisementTypeEntity getType() {
		return type;
	}
	public void setType(AdvertisementTypeEntity type) {
		this.type = type;
	}
	public Date getStartDate() {
		return startDate;
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	public Date getExpireDate() {
		return expireDate;
	}
	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}
	public Collection<AttachmentEntity> getAttachments() {
		return attachments;
	}
	public void setAttachments(Collection<AttachmentEntity> attachments) {
		this.attachments = attachments;
	}
}
